import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { Logger, ValidationPipe } from '@nestjs/common';
import * as config from 'config';

// 配置参数
const PORT = config.get('port');
const PREFIX = config.get('prefix');

async function bootstrap() {
  const logger: Logger = new Logger();

  const app = await NestFactory.create(AppModule);

  app.setGlobalPrefix(PREFIX);
  app.useGlobalPipes(
    new ValidationPipe({
      transform: true,
      whitelist: true,
      forbidNonWhitelisted: false
    })
  );

  await app.listen(PORT, () => {
    logger.log(`服务已经启动，接口请访问：http://localhost:${PORT}/${PREFIX}`);
  });
}
bootstrap();
